class Ability
  include CanCan::Ability

  def initialize(user)
    # Define abilities for the passed in user here. For example:
    #
      user ||= User.new # guest user (not logged in)
      if user.role? :admin
        can :manage, :all
      # 会员可以读所有
      elsif user.role? :member
        can :read, :all
        # 新注册用户不能发帖
        unless user.new_leaguer?
          can :create, Topic
        end
        # can :favorite, Topic
        # can :unfavorite,Topic
      elsif

       cannot :mange,:all
       basic_read_only
      end


  end

  def basic_read_only
    can :read, Topic
    can :read, Reply

  end
end

